# 6.3.1 遍历字典
user_0 = {
    'username': 'efermi',
    'first': 'enrico',
    'flast': 'fermi'
}

for key, value in user_0.items():
    print("\nKey: " + key)
    print("Value: " + value)


print("\n")
favorite_languages = {
    'jen': 'python',
    'sarah': 'c',
    'edward': 'ruby',
    'phil': 'python',
}

# 这里的name就是键，language就是值
for name, language in favorite_languages.items():
    print(name.title() + "'s favorite language is " + language.title())

# 6.3.2 遍历字典中的所有键 以及
print("\n")
favorite_languages = {
    'jen': 'python',
    'sarah': 'c',
    'edward': 'ruby',
    'phil': 'python',
}
friends = ['jen', 'sarah']
for name in favorite_languages.keys():
    print(name.title())
    if name in friends:
        print("Hi " + name.title() + ", I sse you favorite language is " + favorite_languages[name].title() + "!\n")


favorite_languages = {
    'jen': 'python',
    'sarah': 'c',
    'edward': 'ruby',
    'phil': 'python',
}

for name in sorted(favorite_languages.keys()):
    print(name.title() + ", tank you for taking the poil.")

# 6.3.4 遍历字典中的所有值
print("\nThe following languages have been mentioned:")
# for language in favorite_languages.values():

# 重复元素的列表调用set()
for language in set(favorite_languages.values()):
    print(language.title())